﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebFormPurchases.aspx.cs" Inherits="OnlineReservation.WebFormPurchases" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
    <asp:UpdatePanel ID="UpdatePanelPurchases" runat="server">
        <ContentTemplate>
            Filter by status: <asp:DropDownList ID="DropDownStatus" runat="server" AutoPostBack="true">            
                <asp:ListItem>ordered</asp:ListItem>
                <asp:ListItem>delivered</asp:ListItem>
            </asp:DropDownList>
            Find by ID: 
            <asp:DropDownList ID="DropDownIds" runat="server" 
                DataSourceID="LinqDataSourcePurchasesIds" DataTextField="PurchaseID" 
                DataValueField="PurchaseID" AutoPostBack="True"
                onselectedindexchanged="DropDownIds_SelectedIndexChanged"></asp:DropDownList>
            <asp:LinqDataSource ID="LinqDataSourcePurchasesIds" runat="server" 
                ContextTypeName="DAOTicketReservationSystem.TicketReservationSystemDataContext" 
                EntityTypeName="" TableName="Purchases">
            </asp:LinqDataSource>
            <asp:GridView runat="server" ID="GridViewPurchases" AutoGenerateColumns="False" 
                DataKeyNames="PurchaseID" DataSourceID="LinqDataSourcePurchases" 
                onrowdatabound="GridViewPurchases_RowDataBound"> 
                <Columns>
                    <asp:BoundField DataField="PurchaseID" HeaderText="PurchaseID" 
                        InsertVisible="False" ReadOnly="True" SortExpression="PurchaseID" />
                    <asp:BoundField DataField="EventID" HeaderText="EventID" 
                        SortExpression="EventID" />
                    <asp:TemplateField HeaderText="Event">
                        <ItemTemplate>
                            <%# Eval("Event.EventName") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CustomerName" HeaderText="Customer name" 
                        SortExpression="CustomerName" />
                    <asp:BoundField DataField="Address" HeaderText="Address" 
                        SortExpression="Address" />
                    <asp:BoundField DataField="Status" HeaderText="Status" 
                        SortExpression="Status" />
                    <asp:BoundField DataField="Date" HeaderText="Date ordered" 
                        SortExpression="Date" DataFormatString="{0:d}" />
                    <asp:BoundField DataField="NumberOfTickets" HeaderText="Number of tickets" 
                        SortExpression="NumberOfTickets" />
                    <asp:TemplateField HeaderText=""> 
                        <ItemTemplate>
                            <asp:LinkButton ID="ButtonEditStatus" runat="server" OnClick="ButtonEditStatus_Click" Text="Edit status"/>
                        </ItemTemplate> 
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <div id="DivEdit" runat="server">
                Order status: 
                <asp:DropDownList ID="DropDownListStatus" runat="server">            
                    <asp:ListItem>ordered</asp:ListItem>
                    <asp:ListItem>delivered</asp:ListItem>
                </asp:DropDownList> <br />
                <asp:Button ID="ButtonSave" runat="server" Text="Save" 
                    onclick="ButtonSave_Click" />
                <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" 
                    onclick="ButtonCancel_Click" />
            </div>
            <asp:LinqDataSource ID="LinqDataSourcePurchases" runat="server" 
                ContextTypeName="DAOTicketReservationSystem.TicketReservationSystemDataContext" 
                EntityTypeName="" OrderBy="Date desc" TableName="Purchases" 
                Where="Status == @Status">
                <WhereParameters>
                    <asp:ControlParameter ControlID="DropDownStatus" Name="Status" 
                        PropertyName="SelectedValue" Type="String" />
                </WhereParameters>
            </asp:LinqDataSource>
        </ContentTemplate>
    </asp:UpdatePanel> 
</asp:Content>
